package activities;

import helper.Settings;

import com.example.intellifit.R;

import android.app.Activity;
import android.app.ActivityGroup;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.TextView;

@SuppressWarnings("deprecation")
public class SelectWorkoutActivity extends ActivityGroup {

	private TabHost mTabHost;

	private void setupTabHost() {
		mTabHost = (TabHost) findViewById(android.R.id.tabhost);
		
		mTabHost.setup(getLocalActivityManager());
		mTabHost.getTabWidget().setStripEnabled(false);
	}

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// construct the tabhost
		setContentView(R.layout.activity_selectworkout);

		setupTabHost();

		// Bodyweight tab
		Intent intentBodyweight = new Intent().setClass(this,
				BodyweightActivity_view.class);
		TabSpec tabSpecBweight = mTabHost
				.newTabSpec("Bodyweight")
				.setIndicator(
						createTabView(mTabHost.getContext(), getResources().getString(R.string.tab_bodyweight).toUpperCase()))
				.setContent(intentBodyweight);

		// Weight tab
		Intent intentWeight = new Intent().setClass(this,
				WeightActivity_view.class);
		TabSpec tabSpecWeight = mTabHost.newTabSpec("Weight")
				.setIndicator(createTabView(mTabHost.getContext(), getResources().getString(R.string.tab_weight).toUpperCase()))
				.setContent(intentWeight);
		
		// Endurance tab
				Intent intentEndurance = new Intent().setClass(this,
						EnduranceActivity_view.class);
				TabSpec tabSpecEndo = mTabHost.newTabSpec("Endurance")
						.setIndicator(createTabView(mTabHost.getContext(), getResources().getString(R.string.tab_endurance).toUpperCase()))
						.setContent(intentEndurance);

		// add all tabs
		mTabHost.addTab(tabSpecBweight);
		mTabHost.addTab(tabSpecWeight);
		mTabHost.addTab(tabSpecEndo);
		mTabHost.setCurrentTab(0);
		
		
	}

	

	private static View createTabView(final Context context, final String text) {
		View view = LayoutInflater.from(context)
				.inflate(R.layout.tabs_bg, null);
		TextView tv = (TextView) view.findViewById(R.id.tabsText);
		if (Settings.DISPLAY_HEIGHT <= 800) {
			tv.setTextSize(13);
		}
		tv.setText(text);
		return view;
	}
}